<?php
class LoginAction extends Action {
	public function index(){
		$tmp=LoginAction::log(session('account'), session('password'));
		if($tmp)
			$this->redirect('Main/index');
		$error=$_GET[error];
		if($error!='')
		  	$this->assign('error',$error);
		$this->display();
	}
	public function login(){
		$account=$_GET[account];
		$password=$_GET[password];
		if(LoginAction::log($account,$password)){
			session('account',$account);
			session('password',$password);
			$this->ajaxReturn('true');
		}
		else
			$this->ajaxReturn('false');
	}
	public static function log($account,$password){
		$Dao=D("user");
		$condition=array();
		$condition['account'] =$account;
		$condition['password']=$password;
		trace($condition);
		$list = $Dao->where($condition)->find();
		if($list){
			if(session('user')==NULL)
				session('user',$list);
			return true;
		}
		return false;
	}
	
}

?>